﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using UniRlv.COL;
using UniRlv.Utility;

namespace UniRlv.UI.Main.ManufactureManage
{
    public partial class FrmSelectPrintInfo : DialogBase
    {
        public FrmSelectPrintInfo()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (dgvDetails.CurrentRow != null)
            {
                PrintInfo p = dgvDetails.CurrentRow.DataBoundItem as PrintInfo;

                this.Tag = p;

                this.DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                ShowInfoMessageBox("提示", "先选择打印信息！");
            }
        }

        private void FrmSelectPrintInfo_Load(object sender, EventArgs e)
        {
            #region 初始化模板列表

            Wait();
            string msg = string.Empty;
            List<PrintInfo> liPrintInfos = DALOpr.Query<PrintInfo>("taskid=0", ref msg);

            if (!string.IsNullOrEmpty(msg))
            {
                ShowErrorMessageBox("出现错误", msg);
            }
            else
            {
                if (liPrintInfos == null || liPrintInfos.Count == 0)
                {
                    ShowInfoMessageBox("提示", "缺少打印模信息");
                }

            }

            WaitBack();

            #endregion

            UIHelper.InitDataGridView(dgvDetails);
            dgvDetails.DataSource = liPrintInfos;
        }
    }
}
